<%@ page language="java" pageEncoding="utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>运费列表-编辑</title>
	<link rel="stylesheet" type="text/css" href="../resource/css/base.css" />
	<script type="text/javascript" src="../resource/js/popup/popup.js"></script>
	<script type="text/javascript" src="../resource/js/My97DatePicker/WdatePicker.js"></script>
	<script type="text/javascript" src="../resource/js/prototype.js"></script>
	<s:actionmessage/>
	<script type="text/javascript">
		function $$(name){return document.getElementsByName(name)[0];}
		function $id(name){return document.getElementById(name);}
		
		function setNextCharge(obj){
			$id("leftOweFee").innerText = Number($$("oweFee").value) - Number(obj.value);
			$$("nextChargeFee").value = Number($$("oweFee").value) - Number(obj.value);
		}
		
		function sumbit(){
			var form = document.forms[0];
			var pattern = /^[0-9]+(\.[0-9]{1,2}){0,1}$/;
			
			if($$("realPayFee").value==0){
				alert("请输入收费金额.");
				return false;
			}
			if(!pattern.test($$("realPayFee").value)){
				alert("付费金额数据格式不正确,请重新填写.");
				return false;
			}
			if($$("chargeDate").value==""){
				alert("请输入收费日期.");
				return false;
			}
			if($$("nextChargeFee").value==""){
				alert("请输入欠费金额.");
				return false;
			}
			if($$("nextChargeDate").value==""&&$$("nextChargeFee").value!=0){
				alert("请输入下次缴费日期.");
				return false;
			}
			form.action="update.action";
			form.submit();
		}
	</script>

</head>
<body  oncontextmenu="return false;" leftmargin="8" topmargin="8">
<div class="tip"><span>当前位置:</span>运费管理&nbsp;&gt;&nbsp;编辑&nbsp;&gt;&nbsp;</div>
<s:form name="update" namespace="/chargeRecord">
	<input type="hidden" name="id" value="<s:property value="chargeRecord.id"/>"/>
	<input type="hidden" name="oweFee" value="<s:property value="chargeRecord.oweFee"/>"/>
	<table id="infoTab" class="edittb" cellpadding="2" cellspacing="1">
		<tr bgcolor="#EEF4EA">
			<td height="35" colspan="6">&nbsp;运费信息&nbsp;</td>
		</tr>
		<tr>
			<td class="coln" width="15%">客户名称</td>
			<td width="30%" class="colv" nowrap="nowrap">
				<input type="text" name="clientName" readonly value="<s:property value="chargeRecord.clientInfo.clientName"/>">
			</td>
			<td class="coln" width="15%">联 系 人</td>
			<td width="30%" class="colv" id="linkMan">
				<s:property value="chargeRecord.clientInfo.linkman"/>
			</td>
			<td class="coln" width="15%">联系电话</td>
			<td width="30%" class="colv" id="phone">
				<s:property value="chargeRecord.clientInfo.phone"/>
			</td>
		</tr>
		<tr>
			<td class="coln" width="15%">运货单号</td>
			<td width="30%" class="colv" nowrap="nowrap">
				<input type="text" name="orderId" readonly value="<s:property value="chargeRecord.invoiceOrder.orderId"/>">
			</td>
			<td class="coln">总 运 费</td>
			<td class="colv" id="totalFee">
				<s:property value="invoiceOrders[0][0]"/>
			</td>
			<td class="coln">已付运费</td>
			<td class="colv" id="totalPayFee">
				<s:property value="invoiceOrders[0][1]"/>
			</td>
		</tr>
		<tr>
			<td class="coln"><SPAN style="color: red">*</SPAN> 本次收费金额</td>
			<td class="colv">
				<input type="text" name="realPayFee" value="<s:property value="chargeRecord.realPayFee"/>" onblur="setNextCharge(this);"/>
			</td>
			<td class="coln"><SPAN style="color: red">*</SPAN> 本次收费日期</td>
			<td  class="colv">
				<input type="text" value="<s:date name="chargeRecord.chargeDate" format="yyyy-MM-dd"/>" name="chargeDate" onclick="WdatePicker();" class="Wdate"/>
			</td>
			<td class="coln"> 未支付金额</td>
			<td class="colv" id="leftOweFee"><s:property value="invoiceOrders[0][2]"/></td>
		</tr>
		<tr>
			<td class="coln"><SPAN style="color: red">*</SPAN> 预约付费金额</td>
			<td class="colv">
				<input type="text" value="<s:property value="chargeRecord.nextChargeFee"/>" name="nextChargeFee"/>
			</td>
			<td class="coln"><SPAN style="color: red">*</SPAN> 预约付费日期</td>
			<td class="colv">
				<input type="text" value="<s:date name="chargeRecord.nextChargeDate" format="yyyy-MM-dd"/>" name="nextChargeDate" onclick="WdatePicker();" class="Wdate"/>
			</td>
			<td class="colv" colspan="2"></td>
		</tr>
		<tr>
			<td class="coln">备注</td>
			<td colspan="5" class="colv">
				<textarea name="note"><s:property value="chargeRecord.note"/></textarea>
			</td>
		</tr>
		<tr align="right" bgcolor="#EEF4EA">
			<td height="35" colspan="6" align="center">
				<a href="javascript:history.go(-1)" class="coolbg">&nbsp;返&nbsp;回&nbsp;</a>
				<a href="#" class="coolbg" onclick="return sumbit();">&nbsp;保&nbsp;存&nbsp;</a>
			</td>
		</tr>
	</table>
</s:form>
</body>
</html>
